package com.asiainfo.kbisheet.components.condition
{
	import com.asiainfo.kbisheet.control.MessageControl;
	import com.asiainfo.kbisheet.model.KbsModel;
	import com.asiainfo.kbisheet.vo.WhereVO;
	
	import spark.components.HGroup;
	
	[Event(name="change")]
	
	public class ConditionInput extends HGroup
	{
		public var equalSign:String;
		
		protected var _parent:ConditionItem;
		
		
		[Bindable]
		protected var kbsModel:KbsModel = KbsModel.getInstance();
		
		private var messageControl:MessageControl = new MessageControl();
		
		public function ConditionInput(parent:ConditionItem)
		{
			super();
			_parent = parent;
		}
		
		
		public function get value():String{
			return null;
		}	
		
		protected function isShowCondition():Boolean{
			/*自排除值*/					
			if(_parent.conditionXML.excludes.(!hasOwnProperty('@valid')).exclude.(hasOwnProperty('@value') && @value == value).length() > 0){
				return false;
			}
			
			return ((equalSign != null && equalSign.length > 0) && value != null);
		}
		
		public function getWhereVO():WhereVO{
			if(isShowCondition()){
				var whereVO:WhereVO = new WhereVO();
				whereVO.equalSign = equalSign;
				whereVO.value = value;
				return whereVO;
			}
			else{
				return null;
			}
		}
		
		protected function updateMessage(message:String):void{
			messageControl.updateMessage(message);
		}
		
		protected function onChange(event:Event):void{
			var newEvent:Event = new Event("change");
			dispatchEvent(newEvent);
		}
	}
}